home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / flilib.zip / SLICEFLI.C < prev    next >
C/C++ Source or Header  |  1990-02-20  |  2KB  |  105 lines

  1. /* slicefli.c - This program cut is a demonstration of how to use the FLI.LIB 
  2.     to create FLIC's */
  3.  
  4. #include "aaflisav.h"
  5.  
  6.  
  7. main(int argc, char *argv[])
  8. {
  9. int i;
  10. Errval err;
  11. int ivmode;
  12.  
  13. if (argc != 3)
  14.     {
  15.     puts("slicefli - a program to cut out every other line of a FLI.");
  16.     puts("   usage:  slicefli infile.fli outfile.fli");
  17.     exit(0);
  18.     }
  19. ivmode = dos_get_vmode();
  20. dos_set_vmode(0x13);    /* To VGA/MCGA 320x200 256 color mode */
  21. if (dos_get_vmode() != 0x13)
  22.     {
  23.     puts("Not a vga/mcga display, sorry");
  24.     }
  25. else
  26.     {
  27.     err = convert_fli(argv[1], argv[2]);
  28.     if (err >= AA_SUCCESS)
  29.         {
  30.         fli_play(argv[2]);
  31.         }
  32.     dos_set_vmode(ivmode);
  33.     if (err < AA_SUCCESS)
  34.         puts(fli_error_message(err));
  35.     }
  36. }
  37.  
  38.     /* zero out every other line of a screen */
  39. void slice_screen(Vscreen *s)
  40. {
  41. int i;
  42. Pixel *p;
  43.  
  44. p = s->p;
  45. for (i=0; i<s->h; i+=2)
  46.     {
  47.     i86_bzero(p, s->bpr);
  48.     p += 2*s->bpr;
  49.     }
  50. }
  51.  
  52.  
  53. Errval convert_fli(char *in, char *out)
  54. {
  55. Errval err = AA_SUCCESS;   /* start out optimistic! */
  56. Vscreen *bs;
  57. Fli_head inhead, outhead;
  58. Jfile infile = 0, outfile = 0;
  59. int i;
  60.  
  61. if ((bs = aa_alloc_mem_screen()) == NULL)
  62.     {
  63.     err = AA_ERR_NOMEM;
  64.     goto EXIT;
  65.     }
  66. if ((infile = fli_open(in, &inhead)) < 0)
  67.     {
  68.     err = infile;
  69.     goto EXIT;
  70.     }
  71. if ((outfile = fli_create(out, &outhead, inhead.speed)) < AA_SUCCESS)
  72.     {
  73.     goto EXIT;
  74.     }
  75. for (i=0; i<inhead.frame_count; i++)
  76.     {
  77.     aa_copy_screen(&aa_screen, bs);
  78.     if ((err = fli_next_frame(infile)) < AA_SUCCESS)
  79.         {
  80.         goto EXIT;
  81.         }
  82.     slice_screen(&aa_screen);
  83.     if ((err = fli_write_next(outfile, &outhead, &aa_screen, bs)) < AA_SUCCESS)
  84.         {
  85.         goto EXIT;
  86.         }
  87.     }
  88. if ((err = fli_end(outfile, &outhead, &aa_screen, bs)) < AA_SUCCESS)
  89.     {
  90.     goto EXIT;
  91.     }
  92. EXIT:
  93. if (infile != 0)
  94.     dos_close (infile);
  95. if (outfile != 0)
  96.     dos_close (outfile);
  97. aa_free_mem_screen(bs);
  98. if (err < AA_SUCCESS)
  99.     {
  100.     dos_delete (out);
  101.     }
  102. return(err);
  103. }
  104.  
  105.